package com.base.self.controller;

import com.base.log.LoginAn;
import com.base.result.ResponseResult;
import com.base.self.dto.commodityCallPlan.CommodityCallPlanWebAddDTO;
import com.base.self.dto.commodityCallPlan.CommodityCallPlanWebDelDTO;
import com.base.self.dto.commodityCallPlan.CommodityCallPlanWebListDTO;
import com.base.self.dto.commodityCallPlan.CommodityCallPlanWebUpdateDTO;
import com.base.self.service.ICommodityCallPlanService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.Valid;

/**
 * <p>
 * 话费礼包 前端控制器
 * </p>
 *
 * @author XiFYuW
 * @since 2020-11-18
 */
@RestController
@RequestMapping("/admin/commodityCallPlan")
public class CommodityCallPlanController {

    private final ICommodityCallPlanService iCommodityCallPlanService;

    public CommodityCallPlanController(ICommodityCallPlanService iCommodityCallPlanService) {
        this.iCommodityCallPlanService = iCommodityCallPlanService;
    }

    @GetMapping(value = "/commodityCallPlanIndex")
    @LoginAn
    public ModelAndView commodityCallPlanIndex() {
        return new ModelAndView("self/index_commodity_call_plan");
    }

    @PostMapping(value = "/commodityCallPlanWebList")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityCallPlanWebList(@Valid final CommodityCallPlanWebListDTO commodityCallPlanWebListDTO) {
        return iCommodityCallPlanService.commodityCallPlanWebList(commodityCallPlanWebListDTO);
    }

    @PostMapping(value = "/commodityCallPlanWebAdd")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityCallPlanWebAdd(@Valid final CommodityCallPlanWebAddDTO commodityCallPlanWebAddDTO) {
        return iCommodityCallPlanService.commodityCallPlanWebAdd(commodityCallPlanWebAddDTO);
    }

    @PostMapping(value = "/commodityCallPlanWebUpdate")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityCallPlanWebUpdate(@Valid final CommodityCallPlanWebUpdateDTO commodityCallPlanWebUpdateDTO) {
        return iCommodityCallPlanService.commodityCallPlanWebUpdate(commodityCallPlanWebUpdateDTO);
    }

    @PostMapping(value = "/commodityCallPlanWebDelete")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityCallPlanWebDelete(@Valid final CommodityCallPlanWebDelDTO commodityCallPlanWebDelDTO) {
        return iCommodityCallPlanService.commodityCallPlanWebDelete(commodityCallPlanWebDelDTO);
    }

    @PostMapping(value = "/getCallPlanSelectData")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult getCallPlanSelectData() {
        return iCommodityCallPlanService.getCallPlanSelectData();
    }
}

